package com.dc.controller;

import com.dc.annotation.Log;
import com.dc.common.ResponseResultVO;
import com.dc.entity.WareHouse;
import com.dc.entity.ro.WareHouseRO;
import com.dc.service.WareHouseService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@Api(tags = "危险品管理")
@RestController
@RequestMapping("/wareHouse")
public class WareHouseController {

    @Resource
    private WareHouseService wareHouseService;


    @Log(title = "危险品管理", businessDesc = "增加")
    @ApiOperation(value = "增加", notes = "增加")
    @PostMapping("/insertWareHouse")
    public ResponseResultVO insertWareHouse(@RequestBody WareHouseRO ro) {
        return wareHouseService.insertWareHouse(ro);
    }


    @Log(title = "危险品管理", businessDesc = "修改")
    @ApiOperation(value = "修改", notes = "修改")
    @PostMapping("/updateWareHouse")
    public ResponseResultVO updateWareHouse(@RequestBody WareHouseRO ro) {
        return wareHouseService.updateWareHouse(ro);
    }


    @Log(title = "危险品管理", businessDesc = "删除")
    @ApiOperation(value = "删除", notes = "删除")
    @GetMapping("/deleteWareHouse")
    public ResponseResultVO deleteWareHouse(@RequestParam String id) {
        return wareHouseService.deleteWareHouse(id);
    }

    @ApiOperation(value = "危险品下拉列表", notes = "危险品下拉列表")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "name", value = "危险品名称", paramType = "query", dataType = "String"),
            @ApiImplicitParam(name = "regionName", value = "区域地址", paramType = "query", dataType = "String")
    })
    @GetMapping("/selectWareHouseList")
    public ResponseResultVO selectWareHouseList(@RequestParam(value = "name",required = false) String name, @RequestParam(value = "regionName", required = false) String regionName) {
        return wareHouseService.selectWareHouseList(name,regionName);
    }

    @ApiOperation(value = "分页查询列表", notes = "查询列表")
    @PostMapping("/selectWareHouseListByPage")
    public ResponseResultVO<WareHouse> selectWareHouseListByPage(@RequestBody WareHouseRO ro) {
        return wareHouseService.selectWareHouseListByPage(ro);
    }
}
